import { getVehicleListApi } from '@/services/vehicle';
import { useEffect, useState } from 'react';

export default () => {
  const [vehicles, setVehicles] = useState<any[]>([]);

  const getVehicleList = async () => {
    const { rsCode, body } = await getVehicleListApi({
      pageNo: 1,
      pageSize: 100000,
    });
    if (rsCode === '00000000' && Array.isArray(body?.list)) {
      setVehicles(body.list);
    }
  };

  useEffect(() => {
    getVehicleList();
  }, []);

  return {
    vehicles,
    getVehicleList,
  };
};
